package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.entity.TbOfferLanguage;
import org.apache.ibatis.annotations.Insert;

/**
 * 语言能力数据库访问层
 *
 * @author chenyifan
 * @since 2022-06-17 11:31:12
 */
public interface TbOfferLanguageMapper extends BaseMapper<TbOfferLanguage> {

    @Insert("INSERT INTO tb_offer_language \n" +
            "(language_id, worker_id, offer_id , language_type, qualification, \n" +
            "grant_date, eng_mark, update_time) \n" +
            "SELECT \n" +
            "nextval('hrssseq'), a.HC_NO, b.OfferID, b.LanguageType, b.Qualification, \n" +
            "CASE WHEN b.GrantDate='' THEN NULL WHEN length(b.GrantDate) != 10 THEN NULL WHEN b.GrantDate LIKE '%.%' THEN NULL ELSE STR_TO_DATE(b.GrantDate,'%Y-%m-%d') END, \n" +
            "b.EngMark, NOW() \n" +
            "FROM Offer_Send_Detail a, Offer_LanguageInfo b \n" +
            "WHERE a.id = b.OfferID " )
    void initLanguageRecordFromHrss();
}

